﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace WinForm003
{
    public partial class MainForm : Form
    {
        public MainForm()
        {
            InitializeComponent();
        }

        private void MainForm_Load(object sender, EventArgs e)
        {
            string select = "select * from StudentInfo";

            var data = dBHelper.GetDataTable(select);

            dataGridView1.DataSource = data;

            dataGridView1.ReadOnly = true;

            dataGridView1.SelectionMode = DataGridViewSelectionMode.FullRowSelect;

            dataGridView1.AllowUserToAddRows = false;
        }

        //查询
        private void button1_Click(object sender, EventArgs e)
        {
            var name = textBox1.Text;

            string select = string.Format("select * from StudentInfo where Name like '%{0}%'",name);

            var data = dBHelper.GetDataTable(select);

            dataGridView1.DataSource = data;
        }
    }
}
